<template>
    <div>
        <h1>管理员登录</h1>
        <hr>
        <table class="table">
            <tbody>
                <tr>
                    <td>管理员账号</td>
                    <td><input type="text" v-model="data.Name"></td>
                </tr>
                <tr>
                    <td>管理员密码</td>
                    <td><input type="password" v-model="data.Pass"></td>
                </tr>
                <tr>
                    <td></td>
                    <td><input type="button" value="登录" @click="Deng"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">

import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router = useRouter()
const data = ref({
    "Id": 0,
  "Name": "",
  "Pass": ""
})


const Deng = ()=>{
    if(data.value.Name==""){
        alert('管理员账号不能为空')
        return
    }
    if(data.value.Pass==""){
        alert('管理员密码不能为空')
        return
    }
    axios.get('https://localhost:7206/api/Login/Deng',{params:data.value}).then(res=>{
        if(res.data.Id==-1){
            alert('管理员不存在');
            return
        }
        else{
            if(res.data.Id==-2){
                alert('登录失败，密码错误');
                return
            }
            else{
                alert('登陆成功')
                router.push({path:"/HSHow"})
            }
        }
    })
}



</script>

<style scoped>

</style>